home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / examples.arc / EXAMPL48.PRO < prev    next >
Encoding:
Prolog Source  |  1986-10-07  |  495 b   |  25 lines

  1. /* Program 48 */
  2. /*
  3.   Enter the goal:
  4.       scanner("hello world",X).
  5. */
  6.  
  7. domains
  8.     tok = numb(integer);char(char);name(string)
  9.     tokl = tok*
  10.  
  11. predicates
  12.     scanner(string,tokl)
  13.     maketok(string,tok)
  14.  
  15. clauses
  16.     scanner("",[]).
  17.     scanner(Str,[Tok|Rest]):-
  18.         fronttoken(Str,Sym,Str1),
  19.         maketok(Sym,Tok),
  20.         scanner(Str1,Rest).
  21.     maketok(S,name(S)):- isname(S).
  22.     maketok(S,numb(N)):- str_int(S,N).
  23.     maketok(S,char(C)):- str_Char(S,C).
  24.  
  25.